package cn.tedu.map;

import org.junit.Test;

import java.util.HashMap;
import java.util.Scanner;
/*统计字符串字字符出现次数*/
public class TestMap3 {
    public static void main(String[] args) {
        test();
    }
    @Test
    public static void test(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("Please Input");
        String next = scanner.next();
        HashMap<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < next.length(); i++) {
            char c = next.charAt(i);
            System.out.println((i+1)+"个元素为"+c);
            Integer integer = map.get(c);
            if (integer==null){
                map.put(c,1);
            }else {
                map.put(c,integer+1);
            }
        }
        System.out.println(map);

    }
}
